<template>
	<view class="invite-content">

		<view class="tip-box">
			<view class="title">{{$t('home.invite.recommendCtb')}}</view>
			<!-- <view class="title">{{$t('home.invite.refundUpFees')}}</view> -->

			<view class="steps-box">
				<view class="step-item">
					<view class="dot"></view>
					<view class="u-icon icon u-icon--right">
						<image src="/static/images/invite/invite.sdfdsr3456.svg" style="width: 27px; height: 27px;">
						</image>
					</view>
					<view class="text">{{$t('home.invite.SendInvitations')}}</view>
				</view>
				<view class="step-item">
					<view class="dot"></view>
					<view class="u-icon icon u-icon--right">
						<image src="/static/images/invite/invite.57f2fc0f.svg" style="width: 27px; height: 27px;">
						</image>
					</view>
					<view class="text">{{$t('home.invite.friendsRegister')}}</view>
				</view>
				<view class="step-item">
					<view class="dot"></view>
					<view class="u-icon icon u-icon--right">
						<image src="/static/images/invite/fb737144.svg" style="width: 27px; height: 27px;"></image>
					</view>
					<view class="text">{{$t('home.invite.getRebate')}}</view>
				</view>
			</view>

			<view class="card">
				<view class="code-and-link">
					<view class="tip">{{$t('home.invite.myCode')}}：</view>
					<view class="content"><span>{{user.inviteCode}}</span></view>
					<u-button class="copy-btn" @click="copyContent(user.inviteCode)">{{$t('common.copy')}}</u-button>
				</view>
				<view class="code-and-link">
					<view class="tip">{{$t('home.invite.myLinks')}}：</view>
					<view class="content"><span>{{user.inviteUrl}}</span></view>
					<u-button class="copy-btn" @click="copyContent(user.inviteUrl)">{{$t('common.copy')}}</u-button>
				</view>
				<!-- <u-button shape="circle">下载二维码</u-button> -->
			</view>

			<view class="rule-box">
				<view class="title">{{$t('home.invite.rewardRules')}}</view>
				<view>{{$t('home.invite.rewardRulesContent')}}</view>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		getInviteInfo
	} from "@/api/system/user.js"

	export default {
		data() {
			return {
				user: {}
			};
		},
		onLoad() {
			getInviteInfo().then(rsp => {
				if (rsp.code == 200) {
					this.user = rsp.data;
				}
			})
		},
		methods: {
			copyContent(content) {
				var $this = this;
				uni.setClipboardData({
					data: content,
					success() {
						uni.showToast({
							title: $this.$t('common.copySuccess')
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: $uni-color-bg;
	}

	.invite-content {
		color: $uni-color-font;

		padding: 10px 12px;

		.tip-box {
			box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, .12);
			border-radius: 10px;
			padding: 16px 10px;

			.title {
				font-size: 16px;
				font-weight: 500;
				margin-bottom: 10px;
			}

			.steps-box {
				.step-item {
					position: relative;
					display: flex;
					align-items: center;
					padding: 14px 0;
					border-left: 1px solid #e6e6e6;

					.dot {
						position: absolute;
						left: -4px;
						width: 9px;
						height: 9px;
						background-color: #ccc;
						border-radius: 50%;
					}

					.icon {
						margin: 0 12px;
					}

					.text {
						font-size: 14px;
					}
				}
			}
		}

		.card {
			margin-top: 10px;
			background: $uni-color-box;
			box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, .12);
			border-radius: 10px;
			padding: 16px 10px;

			.code-and-link {
				margin-bottom: 12px;
				height: 32px;
				position: relative;
				border-radius: 16px;
				border: 1px solid $uni-color-primary;
				display: flex;
				align-items: center;

				.tip {
					padding-left: 20px;
					color: $uni-color-subfont;
					font-size: 12px;
				}

				.content {
					flex: 1;
					color: $uni-color-primary;
					font-size: 12px;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;

				}

				.copy-btn {
					color: $uni-color-bg;
					background-color: $uni-color-primary;
					border-color: $uni-color-primary;
					border-width: 1px;
					border-style: solid;
					height: 32px;
					width: 72px;
					border-top-right-radius: 100px;
					border-top-left-radius: 100px;
					border-bottom-left-radius: 100px;
					border-bottom-right-radius: 100px;
				}
			}

		}

		.rule-box {
			background: $uni-color-box;
			box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, .12);
			border-radius: 10px;
			padding: 12px 10px;
			display: flex;
			flex-direction: column;
			align-items: center;
			margin: 10px 0;
		}

	}
</style>